← Back to issue list

core18 built python snap not usable from override-build snippet in another snap's snapcraft.yaml

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#1911062
Type
issue
State
open
Author
~anonymouse67
Labels
Created
2021-01-11 22:06:21.440101+00:00
Updated
2021-02-25 13:39:53.239774+00:00
Closed

Current evaluation

No evaluation has been recorded for this issue yet.

Issue body

Python plugin snaps, such as remarshal: https://github.com/anonymouse64/remarshal/blob/master/snap/snapcraft.yaml, are not directly usable as build-snaps from another python plugin snapcraft.yaml's override-build snippet. Trying to use the snap fails like this: ``` + /snap/bin/toml2json /root/parts/streamdeck-ui/build/pyproject.toml Traceback (most recent call last): File "/snap/remarshal/19/bin/toml2json", line 10, in <module> from importlib.metadata import distribution ModuleNotFoundError: No module named 'importlib.metadata' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/snap/remarshal/19/bin/toml2json", line 13, in <module> from importlib_metadata import distribution ModuleNotFoundError: No module named 'importlib_metadata' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/snap/remarshal/19/bin/toml2json", line 15, in <module> from pkg_resources import load_entry_point File "/root/parts/streamdeck-ui/install/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3238, in <module> @_call_aside File "/root/parts/streamdeck-ui/install/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3222, in _call_aside f(*args, **kwargs) File "/root/parts/streamdeck-ui/install/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3251, in _initialize_master_working_set working_set = WorkingSet._build_master() File "/root/parts/streamdeck-ui/install/lib/python3.6/site-packages/pkg_resources/__init__.py", line 567, in _build_master ws.require(__requires__) File "/root/parts/streamdeck-ui/install/lib/python3.6/site-packages/pkg_resources/__init__.py", line 884, in require needed = self.resolve(parse_requirements(requirements)) File "/root/parts/streamdeck-ui/install/lib/python3.6/site-packages/pkg_resources/__init__.py", line 770, in resolve raise DistributionNotFound(req, requirers) pkg_resources.DistributionNotFound: The 'remarshal==0.10.0' distribution was not found and is required by the application ``` note the paths from the Traceback all have prefixes of $SNAPCRAFT_PART_INSTALL for the snap that is being built, NOT for the snap that was built. In other words the strictly confined, built snap at runtime is tricked into trying to run python from the environment of the currently building snap. One way to work around this as pointed out by cjp256 is to unset the $SNAPCRAFT_PART_INSTALL and $SNAPCRAFT_STAGE environment variables like in this snippet: ``` env -u SNAPCRAFT_PART_INSTALL -u SNAPCRAFT_STAGE -- /snap/bin/toml2json .... ``` however these env vars will always be set for override-build snippets so it's inconvenient and totally unexpected that having these vars set will change the behavior of a strictly confined built snap. To be clear, this bug is about the behavior of the remarshal snap, not about anything in the override-build snippet.

Evaluation history

No evaluation history available.